<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<head>
<script type="text/javascript" src="dwr/interface/FeedHandler.js"></script>
<script type="text/javascript" src="dwr/engine.js"></script>
<script type="text/javascript" src="dwr/util.js"></script>
</head>

<div id="left">
<h3>充实你的信息，让更多人认识你:</h3>
<form name="fans" method="post" action="editFans.html">
<table class="detail">
	<spring:bind path="fans.fansId">
		<input type="hidden" name="id" value="${status.value}" />
	</spring:bind>

	<c:if test="${fans.status==2}">
您的固定链接为：<a href="user/${fans.name}">http://openfans.net/user/${fans.name}</a>
	</c:if>
	<c:if test="${fans.status!=2}">
		<tr>
			<th><label for="name"> <fmt:message key="fans.name" />:</label><br>
			<br>
			<br>
			</th>
			<td><input type="text" name="name" /><br>
			如果您现在设置了<fmt:message key="fans.name" />(为方便起见请用字母与数字的组合)，它将成为您在这里的永久名号，我们会以此生成您的永久链接。您也可以将来再设置。</td>
		</tr>
	</c:if>
	<tr>
		<th><label for="nickName" class="required"> <fmt:message
			key="fans.nickName" />:</label></th>
		<td><spring:bind path="fans.nickName">
			<input type="text" name="${status.expression}"
				value="${status.value}" />
			<span class="fieldError">${status.errorMessage}</span>
		</spring:bind></td>
	</tr>
	<tr>
		<th><label for="email" class="required"> <fmt:message
			key="fans.email" />:</label></th>
		<td><spring:bind path="fans.email">
			<input type="text" name="${status.expression}"
				value="${status.value}" readonly />
			<span class="fieldError">${status.errorMessage}</span>
		</spring:bind></td>

	</tr>

	<tr>
		<th><label for="blog" class="required"> <fmt:message
			key="fans.blog" />:</label></th>
		<td><spring:bind path="fans.blog">
			<input type="text" name="${status.expression}"
				value="${status.value}" />
			<span class="fieldError">${status.errorMessage}</span>
		</spring:bind></td>
	</tr>

	<tr>
		<th><label for="descn" class="required"> <fmt:message
			key="fans.descn" />:</label></th>
		<td><spring:bind path="fans.descn">
			<input type="text" name="${status.expression}"
				value="${status.value}" />
			<span class="fieldError">${status.errorMessage}</span>
		</spring:bind></td>
	</tr>
	<tr>
		<th><label for="city" class="required"> <fmt:message
			key="fans.city" />:</label></th>
		<td><spring:bind path="fans.city">
			<input type="text" name="${status.expression}"
				value="${status.value}" />
			<span class="fieldError">${status.errorMessage}</span>
		</spring:bind></td>
	</tr>
	<tr>
		<th><label for="icon" class="required"> <fmt:message
			key="fans.icon" />:</label></th>
		<td><img src="${fans.icon}" width="60px" /><a
			href="uploadFansIcon.html">上传图像</a></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td><input type="submit" class="button" name="save" value="修改" />
		<input type="button" class="button" name="cancel" value="取消"
			onclick="javascript:history.back(-1)" /></td>
	</tr>
</table>
</form>
</div>

<div id="right">
<h3>管理你的feed</h3>
<div id="feeds"></div>
<div id="wait" style="display:none"></div>
<p><a href="newFeed.html">增加feed</a>
<c:if test="${fans.name=='pesome'}">&nbsp;&nbsp;<a href="javascript:refreshAll()" title="将新的日志更新过来">全部导入</a></c:if>

<script type='text/javascript'>
	function refresh(i){	
		$$("wait").innerHTML="正在跟服务器交互，更新时间较长，请等待。。。";
		$$("wait").style.display="inline";
		FeedHandler.refreshFeed(refreshFeed,i);
	}
	
    var refreshFeed = function(data)
    {
     if (data=="ok"){
	      $$("wait").innerHTML="更新成功，已将你最新的日志入库";
      }
      else{
      	$$("wait").innerHTML="更新失败，请检查feed地址，并重试";
      }
    }
    
    function remove(i){
    if(!confirm("你确定要取删除这个Feed吗"))
  	    	return;
    $$("wait").innerHTML="正在跟服务器交互。。。";
	$$("wait").style.display="inline";
    FeedHandler.removeFeed(reomveFeed,i);
    }
    
    var reomveFeed = function(data)
    {
     if (data=="ok"){
	      $$("wait").innerHTML="更新成功已删除此feed";
	      refreshFeeds();
      }
      else{
      	$$("wait").innerHTML="更新失败";
      }
    }
    
       function refreshFeeds()
    {
    	// $("#feeds").load("listFansFeed.ajax");
    	var xmlhttp = getHttpRequest();
		xmlhttp.open("post","listFansFeed.ajax",false);
		xmlhttp.send("");
       $$("feeds").innerHTML=xmlhttp.responseText;
    }
	
    refreshFeeds();
    
    <c:if test="${fans.name=='pesome'}">
    function refreshAll(){	
		$$("wait").innerHTML="正在跟服务器交互，更新时间较长，请等待。。。";
		$$("wait").style.display="inline";
		FeedHandler.refreshAllFeed(refreshAllFeed);
	}
	
    var refreshAllFeed = function(data)
    {
     if (data=="ok"){
	     $$("wait").innerHTML="更新成功，已将全部最新的日志入库";
      }
      else{
      	$$("wait").innerHTML="更新失败，并重试";
      }
    }
    </c:if>
    
  </script> <br>
<br>
<div class="tips">
提示：请您使用自己原创blog的feed地址，增加或更新feed后，您可以点击“立即导入”链接，立刻对您的feed进行读取和入库，让大家更早看到您的文章。
</div>
</div>

<script type="text/javascript">
    document.forms["fans"].elements["nickName"].focus();
</script>

<v:javascript formName="fans" staticJavascript="false" xhtml="true"
	cdata="false" />
<script type="text/javascript"
	src="<c:url value="/scripts/validator.jsp"/>"></script>
